<?php include template("header"); ?>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="761"><marquee direction="left" scrollamount="3" onMouseOver="this.stop();" onMouseOut="this.start();">

      <span class="STYLE7">滚动公告：</span>
	  <?php foreach($newsList as $array){ ?>
	  <span class="STYLE8" style="margin-right:15px"><a href="news.php?contentid=<?php echo $array['id'];?>" class="link1"><?php echo $array['title'];?>&nbsp;&nbsp;[<?php echo date("Y-m-d",$array['posttime']);?>]</a></span>
	  <?php } ?>
    </marquee></td>
    <td width="189" align="center">
	 <select name="select" id="select" onchange="document.location.href='photo_list.php?order='+this.value">
		<option value="votenum" <?php if($order=='votenum'){echo "selected";} ?>>按发布时间排序</option>
		<option value="createtime" <?php if($order=='createtime'){echo "selected";} ?>>按票数人气排列</option>
	  </select>

    </td>
  </tr>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="25"><img src="images/img_photo_top.jpg" width="950" height="25" /></td>
  </tr>
  <tr>
    <td align="center" background="images/img_photo_middle.jpg">
    <?php 
    for($i=0;$i<sizeof($imageList);$i=$i+4){
    ?>
    <table width="900" border="0" cellspacing="0" cellpadding="0">
      <tr>

        <td align="center" valign="middle"><table width="900" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="225" align="center">
			<?php if(!empty($imageList[$i]['thumburl'])){?>
			<table width="173" border="0" cellpadding="0" cellspacing="1" >
              <tr>
                <td>
				
				<a href="photo.php?id=<?php echo $imageList[$i]['id'];?>">
				<img src="<?php echo $imageList[$i]['thumburl'];?>"  onload="AutoResizeImage(this)"  style="border:2px #FFFFFF solid;" />
				
				</a>
				</td>
              </tr>
            </table>
			<?php }?>
			</td>
            <td width="225" align="center">
			<?php if(!empty($imageList[$i+1]['thumburl'])){?>
			<table width="173" border="0" cellpadding="0" cellspacing="1" >
              <tr>
                <td>
				<a href="photo.php?id=<?php echo $imageList[$i+1]['id'];?>"><img src="<?php echo $imageList[$i+1]['thumburl'];?>" onload="AutoResizeImage(this)" style="border:2px #FFFFFF solid;" /></a>
				</td>
              </tr>
            </table>
			<?php }?>
			
			</td>
            <td width="225" align="center">
			<?php if(!empty($imageList[$i+2]['thumburl'])){?>
			<table width="173" border="0" cellpadding="0" cellspacing="1" >
              <tr>
                <td>
				<a href="photo.php?id=<?php echo $imageList[$i+2]['id'];?>"><img src="<?php echo $imageList[$i+2]['thumburl'];?>" style="border:2px #FFFFFF solid;" onload="AutoResizeImage(this)" /></a>
				</td>
              </tr>
            </table>
			<?php }?>
			</td>
            <td width="225" align="center">
			<?php if(!empty($imageList[$i+3]['thumburl'])){?>
			<table width="173" border="0" cellpadding="0" cellspacing="1" >
              <tr>
                <td>
				<a href="photo.php?id=<?php echo $imageList[$i+3]['id'];?>"><img src="<?php echo $imageList[$i+3]['thumburl'];?>" style="border:2px #FFFFFF solid;"  onload="AutoResizeImage(this)" /></a>
				</td>
              </tr>
            </table>
			<?php }?>
			</td>
          </tr>
          <tr>
            <td height="30" align="center">
			<?php if(!empty($imageList[$i]['title'])){ ?>
			<span class="STYLE9"><?php echo $imageList[$i]['title'];?></span>
			<?php } ?>
			</td>
            <td align="center">
			<?php if(!empty($imageList[$i+1]['title'])){ ?>
			<span class="STYLE9"><?php echo $imageList[$i+1]['title'];?></span>
			<?php } ?>
			</td>
            <td align="center">
			<?php if(!empty($imageList[$i+2]['title'])){ ?>
			<span class="STYLE9"><?php echo $imageList[$i+2]['title'];?></span>
			<?php } ?>
			</td>
            <td align="center">
			<?php if(!empty($imageList[$i+3]['title'])){ ?>
			<span class="STYLE9"><?php echo $imageList[$i+3]['title'];?></span>
			<?php } ?>
			</td>
          </tr>
          <tr>
            <td height="30" align="center">
			<?php if(!empty($imageList[$i]['title'])){ ?>
			<table width="200" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" bgcolor="#999999">
				<?php if(!empty($imageList[$i]['votenum'])){ ?>
				<strong>已获得 <span class="STYLE13"><?php echo $imageList[$i]['votenum'];?></span> 票</strong>
				<?php } ?>
				</td>
                <td width="80" height="30" align="left" bgcolor="#999999">
				
				<input type="button" name="button4" id="button4" value="投票"  onclick="vote(this,<?php echo $imageList[$i]['id'];?>)"/>
			
				
				</td>
              </tr>
            </table>
			<?php } ?>
			</td>
            <td align="center">
			<?php if(!empty($imageList[$i+1]['title'])){ ?>
			<table width="200" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" bgcolor="#999999">
				<?php if(!empty($imageList[$i+1]['votenum'])){ ?>
				<strong>已获得 <span class="STYLE13"><?php echo $imageList[$i+1]['votenum'];?></span> 票</strong>
				<?php } ?>
				</td>
                <td width="80" height="30" align="left" bgcolor="#999999">
				
				<input type="button" name="button4" id="button4" value="投票"  onclick="vote(this,<?php echo $imageList[$i+1]['id'];?>)"/>
				
				</td>
              </tr>
            </table>
			<?php } ?>
			</td>
            <td align="center">
			<?php if(!empty($imageList[$i+2]['title'])){ ?>
			<table width="200" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" bgcolor="#999999">
				<?php if(!empty($imageList[$i+2]['votenum'])){ ?>
				<strong>已获得 <span class="STYLE13"><?php echo $imageList[$i+2]['votenum'];?></span> 票</strong>
				<?php } ?>
				</td>
                <td width="80" height="30" align="left" bgcolor="#999999">
				
				<input type="button" name="button4" id="button4" value="投票"  onclick="vote(this,<?php echo $imageList[$i+2]['id'];?>)"/>
				
				</td>
              </tr>
            </table>
			<?php } ?>
			</td>
            <td align="center">
			<?php if(!empty($imageList[$i+3]['title'])){ ?>
			<table width="200" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" bgcolor="#999999">				
				<?php if(!empty($imageList[$i+3]['votenum'])){ ?>
				<strong>已获得 <span class="STYLE13"><?php echo $imageList[$i+3]['votenum'];?></span> 票</strong>
				<?php } ?>
				</td>
                <td width="80" height="30" align="left" bgcolor="#999999">
				
				<input type="button" name="button4" id="button4" value="投票"  onclick="vote(this,<?php echo $imageList[$i+3]['id'];?>)"/>
				
				</td>
              </tr>
            </table>
			<?php } ?>
			</td>

          </tr>
        </table></td>
      </tr>
    </table>
    <br />
    <?php
    }
    ?>
    
    <br /></td>
  </tr>
  <tr>
    <td height="21"><img src="images/img_photo_bottom.jpg" width="950" height="21" /></td>
  </tr>
</table>

<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="50" align="center">
     <?php echo $photoPage;?></td>
  </tr>

</table>
<script language="javascript">
function vote(obj,id){
	$.ajax({
		type:"GET",
		cache:false,
		url:"vote.php?id="+id,
		success:function(ret){
			if(ret=="success"){
				alert("投票成功");
				jqobj = $(obj).parent().parent().find("span");
				refreshvote(jqobj,id);
			}else{
				alert(ret);
			}
		}
	});
}

function refreshvote(obj,id){
	$.ajax({
		type:"GET",
		cache:false,
		url:"photo.php?job=getnum&id="+id,
		success:function(ret){
			obj.html(ret);
		}
	});
}
function AutoResizeImage(objImg){
	maxWidth  = 173;
	maxHeight = 112;
	if (typeof(objImg)=='string'){   
		objImg = $(objImg);   
	}   
	var img = new Image();   
	img.onload = function(){   
		var hRatio;   
		var wRatio;   
		var Ratio = 1;   
		var w = img.width;   
		var h = img.height;   
		wRatio = maxWidth / w;   
		hRatio = maxHeight / h;   
		wRatiowRatio = wRatio>1?1:wRatio;   
		hRatiohRatio = hRatio>1?1:hRatio;   
		if (maxWidth ==0 && maxHeight==0){   
			Ratio = 1;   
		}else if (maxWidth==0){//   
			if (hRatio<1)
				Ratio = hRatio;   
		}else if (maxHeight==0){   
			if (wRatio<1) 
				Ratio = wRatio;   
			}else {   
				Ratio = (wRatio<=hRatio?wRatio:hRatio);   
		}   
		if (Ratio<1){   
			ww = w * Ratio;   
			hh = h * Ratio;   
		}   
		objImg.height = h;   
		objImg.width = w;   
		this.onload = function(){}   
	}   
	img.src = objImg.src;   
}
</script>
<?php include template("footer"); ?>